package com.lovo.movie.controller;

import com.lovo.vo.MovieVo;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MovieMQController {
   @Autowired
    RabbitTemplate rabbitTemplate;
    @GetMapping("sendInfo/{info}")
    public boolean sendInfo(@PathVariable("info")String info){
         try{
        rabbitTemplate.convertAndSend("movieExchange","movie.basic",info);
         }catch (Exception e){
             return  false;
         }
         return  true;
    }
    @GetMapping("sendVO")
    public boolean sendVO(){
        try{
            MovieVo vo=new MovieVo();
            vo.setMovieName("沙丘");
            vo.setMovieDate("2021-11-17");
            rabbitTemplate.convertAndSend("movieExchange","movie.basic",vo);
        }catch (Exception e){
            return  false;
        }
        return  true;
    }
}
